package com.atguigu.controller;

import com.atguigu.pojo.User;
import com.atguigu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService ;
    @RequestMapping("/findAll")
    public List<User> findAll() {
        return userService.findUsers() ;
    }

    @RequestMapping("add")
    public void add(User user) {
        userService.saveUser(user);
    }

    @RequestMapping("delete")
    public void delete(Integer id) {
        userService.deleteUserById(id);
    }

    @RequestMapping("update")
    public void update(User user) {
        userService.saveUser(user);
    }

}
